﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.UIDesigner.OutputPropertyListControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:Converters1="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner"
             xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
    <UserControl.Resources>
        <Converters1:OutputPropertyListNameTooltipGenerator x:Key="OutputPropertyNameTooltipGenerator"/>
        <Converters1:OppositeVisibilityConverter x:Key="oppositeVisibilityConverter"/>
        <Converters1:WorkflowOutputsTabTooltipGenerator x:Key="WorkflowOutputsTabTooltipGenerator"/>

        <!-- Styles-->
        <SolidColorBrush x:Key="ListBorder" Color="#828790"/>
        <Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}">
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                        <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <DockPanel Margin="{TemplateBinding Padding}">
                                <ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DockPanel.Dock="Top">
                                    <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,0,2,0" AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </ScrollViewer>
                                <ScrollContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ScrollContentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" KeyboardNavigation.DirectionalNavigation="Local"/>
                            </DockPanel>
                            <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar" Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" Grid.Column="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="false">
                                <Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1" Fill="White" DockPanel.Dock="Left"/>
                                <Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Height="1" Fill="White" DockPanel.Dock="Top"/>
                            </DockPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ListViewStyle1" TargetType="{x:Type ListView}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="#FF042271"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListView}">
                        <Microsoft_Windows_Themes:ListBoxChrome SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" RenderMouseOver="{TemplateBinding IsMouseOver}">
                            <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource ScrollViewerStyle1}">
                                    <Grid>
                                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        <TextBlock HorizontalAlignment="Center" 
                                                   Visibility="{Binding Path=HasItems, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource oppositeVisibilityConverter}}">No Items to be shown.</TextBlock>
                                    </Grid>
                                </ScrollViewer>
                        </Microsoft_Windows_Themes:ListBoxChrome>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ScrollViewerStyle1" TargetType="{x:Type ScrollViewer}">
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                        <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <DockPanel Margin="{TemplateBinding Padding}">
                                <ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DockPanel.Dock="Top">
                                    <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,0,0,0" AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContainerStyle="{DynamicResource GridViewColumnHeaderStyle1}" ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </ScrollViewer>
                                <ScrollContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ScrollContentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" KeyboardNavigation.DirectionalNavigation="Local"/>
                            </DockPanel>
                            <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar" Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" Grid.Column="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="false">
                                <Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1" Fill="White" DockPanel.Dock="Left"/>
                                <Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Height="1" Fill="White" DockPanel.Dock="Top"/>
                            </DockPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <LinearGradientBrush x:Key="GridViewColumnHeaderBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFFFFFFF" Offset="0"/>
            <GradientStop Color="#FFFFFFFF" Offset="0.4091"/>
            <GradientStop Color="#FFF7F8F9" Offset="1"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GridViewColumnHeaderBorderBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFF2F2F2" Offset="0"/>
            <GradientStop Color="#FFD5D5D5" Offset="1"/>
        </LinearGradientBrush>
        <Style x:Key="GridViewColumnHeaderGripper" TargetType="{x:Type Thumb}">
            <Setter Property="Canvas.Right" Value="-9"/>
            <Setter Property="Width" Value="18"/>
            <Setter Property="Height" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource TemplatedParent}}"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Background" Value="{StaticResource GridViewColumnHeaderBorderBackground}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Border Background="Transparent" Padding="{TemplateBinding Padding}">
                            <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <LinearGradientBrush x:Key="GridViewColumnHeaderHoverBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFBDEDFF" Offset="0"/>
            <GradientStop Color="#FFB7E7FB" Offset="1"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GridViewColumnHeaderPressBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FF8DD6F7" Offset="0"/>
            <GradientStop Color="#FF8AD1F5" Offset="1"/>
        </LinearGradientBrush>
        <Style x:Key="GridViewColumnHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFEEF6FF" Offset="0"/>
                        <GradientStop Color="#FFC4E2FF" Offset="0.393"/>
                        <GradientStop Color="#FFDAECFF" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFD2E1F1" Offset="0"/>
                        <GradientStop Color="#FFA7BACC" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Padding" Value="2,0,2,0"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Value="{DynamicResource GridViewColumnHeaderControlTemplate1}" Property="Template"/>
            <Style.Triggers>
                <Trigger Property="Role" Value="Floating">
                    <Setter Property="Opacity" Value="0.4082"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                                <Canvas x:Name="PART_FloatingHeaderCanvas">
                                    <Rectangle Opacity="0.4697" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Fill="#FF000000"/>
                                </Canvas>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="Role" Value="Padding">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                                <Border x:Name="HeaderBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,0,1"/>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="Height" Value="Auto">
                                        <Setter Property="MinHeight" Value="20"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="ButtonFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="2" SnapsToDevicePixels="true"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#F3F3F3" Offset="0"/>
            <GradientStop Color="#EBEBEB" Offset="0.5"/>
            <GradientStop Color="#DDDDDD" Offset="0.5"/>
            <GradientStop Color="#CDCDCD" Offset="1"/>
        </LinearGradientBrush>
        <SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
        <Style x:Key="plusMinusButtonStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
            <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
            <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Grid Width="10" Height="10" x:Name="properties">
                            <Grid Width="10" Height="10" x:Name="plus_grid" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Rectangle Fill="#FFFFFFFF" Stroke="#FF000000" x:Name="rectangle"/>
                                <Rectangle HorizontalAlignment="Center" VerticalAlignment="Center" Width="6" Height="1.5" Fill="#FF000000" Stroke="{x:Null}"/>
                                <Rectangle Fill="#FF000000" Stroke="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="1.5" Height="6" x:Name="rectangle1"/>
                            </Grid>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Fill" TargetName="rectangle">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFDDF0F7" Offset="0"/>
                                            <GradientStop Color="#FF98C8DC" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true"/>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="#ADADAD"/>
                            </Trigger>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="Opacity" TargetName="rectangle1" Value="0"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style TargetType="TextBox">
            <Setter Property="AutomationProperties.AutomationId" Value="{Binding RelativeSource={RelativeSource Self}, Path=Text }"/>
        </Style>
        
        <!--Style for all the TextBlock-->
        <Style TargetType="{x:Type TextBlock}" >
            <Setter Property="AutomationProperties.AutomationId" Value="{Binding RelativeSource={RelativeSource Self}, Path=Text }"/>
        </Style>
        <!--Style for all the ComboBox-->
        <Style TargetType="{x:Type ComboBox}" >
            <Setter Property="AutomationProperties.AutomationId" Value="{Binding RelativeSource={RelativeSource Self}, Path=Text }"/>
        </Style>

        <ControlTemplate x:Key="GridViewColumnHeaderControlTemplate1" TargetType="{x:Type GridViewColumnHeader}">
            <Grid SnapsToDevicePixels="true">
                <Border x:Name="HeaderBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,0,1" Padding="2,2,2,2">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition MaxHeight="7"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2" HorizontalAlignment="Stretch" Padding="{TemplateBinding Padding}" >
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Stretch" Margin="0,0,0,1" x:Name="HeaderContent" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                        </Border>
                    </Grid>
                </Border>
                <Canvas>
                    <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}"/>
                </Canvas>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Background" TargetName="PART_HeaderGripper" Value="Transparent"/>
                    <Setter Property="Background" TargetName="HeaderBorder">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFCDE7FF" Offset="0"/>
                                <GradientStop Color="#FFB2D8FF" Offset="1"/>
                                <GradientStop Color="#FF7FC0FF" Offset="0.357"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="IsPressed" Value="true">
                    <Setter Property="Visibility" TargetName="PART_HeaderGripper" Value="Hidden"/>
                    <Setter Property="Margin" TargetName="HeaderContent" Value="1,1,0,0"/>
                    <Setter Property="Background" TargetName="HeaderBorder">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFA8D0F5" Offset="0"/>
                                <GradientStop Color="#FF95CAFF" Offset="1"/>
                                <GradientStop Color="#FF5FA2E4" Offset="0.357"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="Height" Value="Auto">
                    <Setter Property="MinHeight" Value="20"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        
         <ControlTemplate x:Key="OutputListControlTemplate" TargetType="{x:Type ListViewItem}">
            <StackPanel>
                <GridViewRowPresenter x:Name="rowPresenter" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.RowSpan="1" 
                                      Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
                <Border Padding="0,0,0,0" Visibility="Collapsed" x:Name="descriptionHost" BorderThickness="0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="25"/>
                            <RowDefinition Height="25"/>
                        </Grid.RowDefinitions>        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="{Binding ElementName=col1, Path=ActualWidth}"/>
                            <ColumnDefinition Width="{Binding ElementName=col2, Path=ActualWidth}"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Padding="25,0,0,0" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"
                                   TextTrimming="CharacterEllipsis" HorizontalAlignment="Left"
                                   ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
                                   ToolTipService.ShowOnDisabled="True" Text="Output Label"/>
                        <TextBox Margin="3,3,3,0" Grid.Column="1" Grid.Row="0" 
                                 IsReadOnly="{Binding ElementName=helperReadOnlyField, Path=IsReadOnly}" 
                                 IsEnabled="{Binding ElementName=helperIsEnabledField, Path=IsEnabled}"
                                 ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}" TextChanged="OnOutputTextTextChanged" 
                                 ToolTipService.ShowOnDisabled="True" Text="{Binding Path=OutputLabel}"/>
                        
                        <TextBlock Padding="25,0,0,0" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"
                                   TextTrimming="CharacterEllipsis" HorizontalAlignment="Left"
                                   ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
                                   ToolTipService.ShowOnDisabled="True" Text="Output Type"/>
                        <ComboBox Margin="3,3,3,0" Grid.Column="1" Grid.Row="1" 
                                  IsReadOnly="{Binding ElementName=helperReadOnlyField, Path=IsReadOnly}" 
                                  IsEnabled="{Binding ElementName=helperIsEnabledField, Path=IsEnabled}"
                                  ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}"
                                  Initialized="ComboBox_Initialized" SelectionChanged="OnSelectionChanged"
                                  ToolTipService.ShowOnDisabled="True" SelectedItem="{Binding Path=OutputType}"/>
                    </Grid>
                </Border>
            </StackPanel>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFF1FBFF" Offset="0"/>
                                <GradientStop Color="#FFD5F1FE" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FFCCF0FF"/>
                </Trigger>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFD9F4FF" Offset="0"/>
                                <GradientStop Color="#FF9BDDFB" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FF98DDFB"/>
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="Selector.IsSelectionActive" Value="False"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFEEEDED" Offset="0"/>
                                <GradientStop Color="#FFDDDDDD" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FFCFCFCF"/>
                </MultiTrigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="IsMouseOver" Value="True"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFEAF9FF" Offset="0"/>
                                <GradientStop Color="#FFC9EDFD" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FF98DDFB"/>
                </MultiTrigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <!--For the property name-->
        <DataTemplate x:Key="NameTemplate">
            <Grid Margin="0,3,3,0" DockPanel.Dock="Left" HorizontalAlignment="Left">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="15" />
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <ToggleButton Grid.Column="0" Content="+" HorizontalAlignment="Left" Style="{DynamicResource plusMinusButtonStyle}"
                       AutomationProperties.Name="PlusMinusToggleBtn"
                          Checked="ToggleButton_Checked" Unchecked="ToggleButton_Unchecked" />
                <TextBlock Text="{Binding Path=PropertyPaneDisplayName}" Grid.Column="1"
                       AutomationProperties.Name="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
                           ToolTip="{Binding Converter={StaticResource OutputPropertyNameTooltipGenerator}, Path=.}" 
                           ToolTipService.ShowOnDisabled="True"
                           TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left"/>
            </Grid>
        </DataTemplate>

        <!--For the Output Label template-->
        <DataTemplate x:Key="OutputValueTemplate">
            <TextBlock TextWrapping="NoWrap" AutomationProperties.Name="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
                           ToolTip="{Binding Converter={StaticResource WorkflowOutputsTabTooltipGenerator}, Path=.}" 
                           ToolTipService.ShowOnDisabled="True" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left">
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0}, {1}">
                            <Binding Path="OutputLabel" />
                            <Binding Path="OutputType" />
                        </MultiBinding>
                    </TextBlock.Text>
            </TextBlock>
        </DataTemplate>

    </UserControl.Resources>
    
    <Grid>
        <ListView x:Name="outputPropertiesList" Style="{StaticResource ListViewStyle1}" ItemsSource="{Binding Path=OutputParameters}">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="Template" Value="{StaticResource OutputListControlTemplate}"/>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView AllowsColumnReorder="False">
                    <GridViewColumn Width="100" x:Name="col1" Header="Output Parameters" 
                                    CellTemplate="{StaticResource NameTemplate}"></GridViewColumn>
                    <GridViewColumn Header="Value" x:Name="col2" 
                                    Width="{Binding ElementName=helperField, Path=ActualWidth}" 
                                    CellTemplate="{StaticResource OutputValueTemplate}"></GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        
        <!--This is the hidden helper Grid which does the resizing -->
        <Grid Visibility="Hidden">
            <Grid.ColumnDefinitions>
                <!--Width is bound to width of the first GridViewColumn -->
                <ColumnDefinition Width="{Binding ElementName=col1, Path=ActualWidth}"/>
                <!--Width is set to "Fill"-->
                <ColumnDefinition Width="*"/>
                <!--Correction Width-->
                <ColumnDefinition Width="10"/>
            </Grid.ColumnDefinitions>
            <!--This is the hidden helper Field which is used to bind to, using the "Fill" column of the helper grid-->
            <Grid Grid.Column="1" x:Name="helperField"/>
            <TextBox Grid.Column="2" x:Name="helperReadOnlyField" IsReadOnly="{Binding Path=IsNotEditable}" />
            <TextBox Grid.Column="2" x:Name="helperIsEnabledField" IsEnabled="{Binding Path=IsEditable}" />
        </Grid>
    </Grid>
</UserControl>
